fix: multi-account sync disappearing calendar and stuck import - #2772
Merged
Conversation
Email/password signup then Add account hid the Compass calendar, left "Adding your calendar…" stuck, and could silently fork a new user from the Google sign-in path. Push derived connection state from bootstrap completion, heal missing-resource and reconnect clobber, force-refresh metadata on SSE/focus/poll, attribute local calendars per account, and refuse SIGNUP under an existing session. Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
URL-param tests timed out because a process-wide useSession mock from another file reported authenticated, so ?auth= never opened the modal. Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
Spy the shared BaseApi and window timers so process-wide module mocks cannot hide the coalescing and import-poll behavior, and assert the new hasExistingSession argument on handleGoogleAuth. Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
mock.module leaked into later files and hid BaseApi.get. Use a restored spy and the same global timers as useMinuteTick so import polling stops when the connection settles. Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
mock.module turned refreshUserMetadata into a no-op for later files, and an unrestored BaseApi.get spy hid CalendarList's adapter error path. Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
tyler-dane
marked this pull request as ready for review
August 13, 2026 00:23
Restoring the local Day column made click-to-create land on Compass. Gate that surface with getWritableCalendars so LCV1/LCV2 still hold. Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Email/password signup followed by Settings → Add account hid the original Compass calendar and left "Adding your calendar…" stuck. This PR fixes both the UI attribution and the import-state push/pull path, plus a sign-in fork guard.
Summary
Local calendar vanished.
CalendarListhidprovider === "local"once any Google connection existed (LCV3). That premise is false for email/pw signup → add Google. Day view also dropped local columns while Week kept them. Empty account groups were filtered out, so a just-connected account had no section to hang "Adding your calendar…" on.Import never converged in the UI.
importing → healthywas computed lazily only on syncGET /connections. Bootstrap completion did not push a connection invalidation. SSE handlers refreshed metadata withoutforce, focus reconciliation was disabled during IMPORTING, and a missing events resource stayedimportingforever. Reconnect clobberedlastHealthyAt, so an established account looked like a first import.Add account could bind to reconnect.
useConnectGooglepinnedconnectionIdwhenever any account wasRECONNECT_REQUIRED, so Settings "Add account" became a reconnect and failed with "Reconnect account does not match the named connection".Sign-in fork. An authenticated user hitting the Google sign-in path (
?auth=→POST /api/signinup) with an unrecognized Google account silently created a new Compass user.Sync — deterministic import-state convergence
refreshConnectionStateafterbootstrapCatchupandsubscriptionMaintainunsupported setbootstrapStatetoready(try/catch; never fail the job).updatedAtas the stall basis →delayedafterBOOTSTRAP_STALLED_AFTER_MS.calendarListSyncper connection so discovery heals resource-less calendars.lastSyncedAt/lastHealthyAtmove to$setOnInsertso reconnect does not clobber them.Web — metadata refresh discipline
refreshUserMetadata({ force: true }).connecting/importing/catchingUp.Web — sidebar + Day view
getWritableCalendars/getDefaultTargetCalendar).Web — Add account
useConnectGoogle({ newAccount: true })always begins with{}. Settings Accounts section uses it.Auth fork guard
?auth=is ignored (and stripped) while a session exists.handleGoogleAuthrefuses SIGNUP wheninput.sessionis present:"You're already signed in — use Settings → Add account to connect this Google account."Architecture invariants:
docs/architecture/multi-account-sync.md.Simplicity
Kept zustand for user metadata (refresh discipline, not a store migration).
refreshConnectionStateremains the only derived-state writer. No second SSE push channel. The Day create gate reusesgetWritableCalendarsinstead of a new local-exclusion rule.Automated validation
newAccount,?auth=while signed in, SIGNUP-under-session).Independent review
Confirmed finding fixed: Day click-to-create on the restored local column after Google connect (LCV1/LCV2). Residual: dragging a Google event onto the local Day column can still retarget it; duplicate sidebar headings if Compass email equals a connected Google email; SIGNUP guard runs after SuperTokens
signInUpPOST.Test plan
bun test:sync— 900 passbun test:web— 2195 pass, then DayCalendarGrid 31 pass after the create-target fixbun test:backend— 307 pass, 1 skipbun type-checkbun lint(pre-existing warnings only)